﻿using System;
using System.Data.SqlTypes;
using System.Web.Mvc;
using System.Globalization;

public static class ServiciosExtensions
{
    public static string EtiquetaFor(this HtmlHelper helper, string target, string text)
    {
        return String.Format("<label for='{0}'>{1}</label>", target, text);

    }

    public static string Etiqueta(this HtmlHelper helper, string text)
    {
        return String.Format("<label>{0}</label>", text);

    }

    public static string Message(this HtmlHelper helper, object text)
    {
        if (text != null)
        {
            return String.Format("<span class=\"message-box\">{0}</span>", text.ToString());
        }
        else return String.Empty;

    }

    public static string NombreEstado(this HtmlHelper helper, string value)
    {
        switch (value)
        {
            case "A": return "Activo";
            case "P": return "Pendiente";
            case "B":
            case "I": return "Baja";
            default: return "Pendiente";
        }
    }

    public static bool isDateNull(this HtmlHelper helper, DateTime dt)
    {
        return (dt <= SqlDateTime.MinValue.Value);
        
    }

    public static string formatoFecha(this HtmlHelper helper)
    {
        string format = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.ToLower();
        return format.Replace("yyyy", "yy");
    }

    public static string separadorNumeroDecimal(this HtmlHelper helper)
    {
        return CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator;
    }
}